package com.whfc.wxmp.api.emp.controller;

import com.whfc.common.base.BaseController;
import com.whfc.common.result.Result;
import com.whfc.common.result.ResultUtil;
import com.whfc.wxmp.annotation.CurrentWxUser;
import com.whfc.emp.dto.AppEmpBaiDuFaceAttendDTO;
import com.whfc.fuum.entity.WxUser;
import com.whfc.wxmp.api.emp.service.WxEmpFaceAttenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 小程序中的人员人脸识别考勤
 */
@RestController
@RequestMapping("/mp/api/emp")
public class WxEmpFaceAttenController extends BaseController {

    @Autowired
    private WxEmpFaceAttenService wxEmpFaceAttenService;

    @PostMapping("/faceAtten/add")
    public Result bindEmp(@CurrentWxUser WxUser user, @Validated @RequestBody AppEmpBaiDuFaceAttendDTO request) {
        logger.info("微信===================人脸考勤");
        wxEmpFaceAttenService.add(user, request);
        return ResultUtil.success();
    }

    @GetMapping("/gps/ckeck")
    public Result ckeck(@CurrentWxUser WxUser wxUser,
                        @RequestParam("lng") Double lng,
                        @RequestParam("lat") Double lat,
                        @RequestParam("deptId") Integer deptId) {
        logger.info("微信校验经纬度是否在地理围栏,经度={},维度={},项目id={}",lng,lat,deptId);
        List<String> data = wxEmpFaceAttenService.ckeckGps(lng,lat,deptId);
        return ResultUtil.success(data.size() >0 );
    }
}
